package org.nowcoder.leetcode.bit;

/**
 * Title  : 136. Single Number
 * Source : https://leetcode.cn/problems/single-number/?envType=study-plan-v2&envId=top-interview-150
 * Author : XrazYang
 * Date   : 2023-08-24
 */

public class LeetCode_136 {
    /**
     * 异或运算⊕三个性质：
     * 1. a ⊕ 0 = a
     * 2. a ⊕ a = 0
     * 3.异或运算满足交换律和结合律
     */
    public int singleNumber(int[] nums) {
        int result = 0;
        for (int num : nums) {
            result ^= num;
        }
        return result;
    }
}
